package gl.uitls;

import android.util.Log;

import gl.android.biyiqing.BuildConfig;

public class Lg {
	private static final boolean DEBUG = BuildConfig.DEBUG;
//	private static final boolean DEBUG = true;
	public static void i(Object tag, Object msg) {
		if (DEBUG && msg != null && tag != null) {
			Log.i(tag.getClass().getSimpleName(), msg.toString());
		}
	}

	public static void e(Object tag, Object msg) {
		if (DEBUG && msg != null && tag != null) {
			Log.e(tag.getClass().getSimpleName(), msg.toString());
		}
	}
	public static void d(Object tag, Object msg) {
	    if (DEBUG && msg != null && tag != null) {
	        Log.d(tag.getClass().getSimpleName(), msg.toString());
	    }
	}
	
    public static void i(String msg) {
        StackTraceElement[] mStackTraces = Thread.currentThread().getStackTrace();
        StackTraceElement s = mStackTraces[3];
//        for (int i = 0; i < mStackTraces.length; i++) {
//            
//            System.out.format(" ClassName:%d\t%s\n", i, s.getClassName());
//            System.out.format("MethodName:%d\t%s\n", i, s.getMethodName());
//            System.out.format("  FileName:%d\t%s\n", i, s.getFileName());
//            System.out.format("LineNumber:%d\t%s\n\n", i, s.getLineNumber());
//        }
        Log.i(s.getClassName(), s.getMethodName()+"(line:"+s.getLineNumber()+") :\n "+msg);
    }
    public static void d(String msg) {
        StackTraceElement[] mStackTraces = Thread.currentThread().getStackTrace();
        StackTraceElement s = mStackTraces[3];
        Log.d(s.getClassName(), s.getMethodName()+"(line:"+s.getLineNumber()+") :\n "+msg);
    }
    public static void e(String msg) {
        StackTraceElement[] mStackTraces = Thread.currentThread().getStackTrace();
        StackTraceElement s = mStackTraces[3];
        Log.e(s.getClassName(), s.getMethodName()+"(line:"+s.getLineNumber()+") :\n "+msg);
    }
}
